package edu.bkcloud08.portal.services;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DatabaseServiceImpl implements DatabaseService{
	private Connection conn = null ;
	public Connection getConnection(String host, String port, String database, String username, String password){
		if(conn == null){
			try{
				conn = DriverManager.getConnection("jdbc:mysql://" + host + "/" + database + "?" +
			                    "user="+username + "&password=" + password) ;
			}catch(SQLException ex){
				// handle any errors
			    System.out.println("SQLException: " + ex.getMessage());
			    System.out.println("SQLState: " + ex.getSQLState());
			    System.out.println("VendorError: " + ex.getErrorCode());
			}
		}
		return conn ;
	}
}
